<?php
namespace app\admin\validate;

class Admin extends Base
{
    protected $rule=[
        'user_name'=>'min:2|max:20',
        'password'=>'require'
    ];
    protected $message=[
        'user_name.min'=>'用户名最小长度不能少于2个字符',
        'user_name.max'=>'用户名最大长度不能超过20个字符',
        'user_name.require'=>'用户名不能为空',
        'password'=>'密码不能为空'
    ];
    protected $scene=[
        'add'=>['user_name','password'],
        'edit'=>['user_name'],
    ];
    public function sceneLogin()
    {
        return $this->only(['user_name','password'])
//            ->remove('user_name','require')
            ->append('user_name','require');
    }
}